//package com.hmall.cart.config;
//
//import com.alibaba.csp.sentinel.slots.block.RuleConstant;
//import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule;
//import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRuleManager;
//import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
//import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
//import org.springframework.context.annotation.Configuration;
//
//import javax.annotation.PostConstruct;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * @author fjh
// */
//@Configuration
//public class SentinelRuleConfiguration {
//
//    @PostConstruct
//    public void initRules() {
//        // 加载流控规则
//        List<FlowRule> rules = new ArrayList<>();
//        FlowRule rule = new FlowRule();
//        rule.setResource("yourResourceName");
//        rule.setGrade(RuleConstant.FLOW_GRADE_QPS);
//        rule.setCount(1); // QPS阈值
//        rules.add(rule);
//        FlowRuleManager.loadRules(rules);
//
//        // 加载熔断规则（可选）
//        List<DegradeRule> degradeRules = new ArrayList<>();
//        DegradeRule degradeRule = new DegradeRule();
//        degradeRule.setResource("yourResourceName");
//        degradeRule.setGrade(RuleConstant.DEGRADE_GRADE_RT);
//        degradeRule.setCount(100); // RT阈值
//        degradeRules.add(degradeRule);
//        DegradeRuleManager.loadRules(degradeRules);
//    }
//}